]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenShield: Drop seat state check after grabs
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 30 Dec 2025 13:39:05 +0000 (14:39 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 19 Jan 2026 16:28:44 +0000 (16:28 +0000)
Grabs are non-failable now, we do not need to check for
the backend seat actually having been able to perform the
request.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4020>

js/ui/screenShield.js

index 6803d3f0369729ae4ec570cd2d8f769498b4328d..9af1f791a6f3268ea99b217f204f00dc3d1f9e8c 100644 (file)
@@ -112,7 +112,7 @@ export class ScreenShield extends Signals.EventEmitter {
         this._lockSettings = new Gio.Settings({schema_id: LOCKDOWN_SCHEMA});
         this._lockSettings.connect(`changed::${DISABLE_LOCK_KEY}`, this._syncInhibitor.bind(this));
 
-        this._isModal = false;
+        this._grab = null;
         this._isGreeter = false;
         this._isActive = false;
         this._isLocked = false;
@@ -191,19 +191,12 @@ export class ScreenShield extends Signals.EventEmitter {
     }
 
     _becomeModal() {
-        if (this._isModal)
-            return true;
-
-        const grab = Main.pushModal(Main.uiGroup, {actionMode: Shell.ActionMode.LOCK_SCREEN});
-
-        // We expect at least a keyboard grab here
-        this._isModal = (grab.get_seat_state() & Clutter.GrabState.KEYBOARD) !== 0;
-        if (this._isModal)
-            this._grab = grab;
-        else
-            Main.popModal(grab);
+        if (this._grab)
+            return;
 
-        return this._isModal;
+        this._grab = Main.pushModal(Main.uiGroup, {
+            actionMode: Shell.ActionMode.LOCK_SCREEN,
+        });
     }
 
     async _syncInhibitor() {
@@ -257,19 +250,7 @@ export class ScreenShield extends Signals.EventEmitter {
             return;
         }
 
-        if (!this._becomeModal()) {
-            // We could not become modal, so we can't activate the
-            // screenshield. The user is probably very upset at this
-            // point, but any application using global grabs is broken
-            // Just tell them to stop using this app
-            //
-            // XXX: another option is to kick the user into the gdm login
-            // screen, where we're not affected by grabs
-            Main.notifyError(
-                _('Unable to lock'),
-                _('Lock was blocked by an app'));
-            return;
-        }
+        this._becomeModal();
 
         if (this._activationTime === 0)
             this._activationTime = GLib.get_monotonic_time();
@@ -339,14 +320,7 @@ export class ScreenShield extends Signals.EventEmitter {
     }
 
     showDialog() {
-        if (!this._becomeModal()) {
-            // In the login screen, this is a hard error. Fail-whale
-            const error = new GLib.Error(
-                Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED,
-                'Could not acquire modal grab for the login screen. Aborting login process.');
-            global.context.terminate_with_error(error);
-        }
-
+        this._becomeModal();
         this.actor.show();
         this._isGreeter = Main.sessionMode.isGreeter;
         this._isLocked = true;
@@ -571,10 +545,9 @@ export class ScreenShield extends Signals.EventEmitter {
         if (this._dialog && !this._isGreeter)
             this._dialog.popModal();
 
-        if (this._isModal) {
+        if (this._grab) {
             Main.popModal(this._grab);
             this._grab = null;
-            this._isModal = false;
         }
 
         this._longLightbox.lightOff();
@@ -669,13 +642,7 @@ export class ScreenShield extends Signals.EventEmitter {
             return;
         }
 
-        // Warn the user if we can't become modal
-        if (!this._becomeModal()) {
-            Main.notifyError(
-                _('Unable to lock'),
-                _('Lock was blocked by an app'));
-            return;
-        }
+        this._becomeModal();
 
         // Clear the clipboard - otherwise, its contents may be leaked
         // to unauthorized parties by pasting into the unlock dialog's